package com.ruoyi.xh.controller;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.core.page.TablePageDataInfo;
import com.ruoyi.common.core.domain.CommentResult;
import com.ruoyi.xh.domain.XhAdminLog;
import com.ruoyi.xh.service.IXhAdminLogService;

/**
 * 备份Controller
 *
 * @author songjw
 * @date 2024-12-13
 */
@Api(tags = "备份Controller",value = "备份Controller")
@RestController
@RequestMapping("/xh/adminLog")
public class XhAdminLogController extends BaseController {

    @Autowired
    private IXhAdminLogService xhAdminLogService;

    /**
     * 查询备份列表
     */
    @PreAuthorize("@ss.hasPermi('xh:adminLog:list')")
    @GetMapping("/list")
    @ApiOperation("查询备份列表")
    public TablePageDataInfo<XhAdminLog> list(XhAdminLog xhAdminLog) {
        return TablePageDataInfo.success(xhAdminLogService.selectXhAdminLogList(xhAdminLog));
    }

    /**
     * 获取备份详细信息
     */
    @PreAuthorize("@ss.hasPermi('xh:adminLog:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation("获取备份详细信息")
    public CommentResult<XhAdminLog> getInfo(@PathVariable("id") Long id) {
        return CommentResult.success(xhAdminLogService.selectXhAdminLogById(id));
    }

    /**
     * 新增备份
     */
    @PreAuthorize("@ss.hasPermi('xh:adminLog:add')")
    @Log(title = "备份", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation("新增备份")
    public CommentResult<XhAdminLog> add(@RequestBody XhAdminLog xhAdminLog) {
            xhAdminLogService.insertXhAdminLog(xhAdminLog);
        return CommentResult.success();
    }

    /**
     * 修改备份
     */
    @PreAuthorize("@ss.hasPermi('xh:adminLog:edit')")
    @Log(title = "备份", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation("修改备份")
    public CommentResult<XhAdminLog> edit(@RequestBody XhAdminLog xhAdminLog) {
            xhAdminLogService.updateXhAdminLog(xhAdminLog);
        return CommentResult.success();
    }

    /**
     * 删除备份
     */
    @PreAuthorize("@ss.hasPermi('xh:adminLog:remove')")
    @Log(title = "备份", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    @ApiOperation("删除备份")
    public CommentResult<XhAdminLog> remove(@PathVariable Long[] ids) {
            xhAdminLogService.deleteXhAdminLogByIds(ids);
        return CommentResult.success();
    }
}
